[IA64] ia64 counter part of 19374:e655cb27d085.
authorIsaku Yamahata <yamahata@valinux.co.jp>
Fri, 27 Mar 2009 01:54:08 +0000 (10:54 +0900)
committerIsaku Yamahata <yamahata@valinux.co.jp>
Fri, 27 Mar 2009 01:54:08 +0000 (10:54 +0900)
This patch is the ia64 counter part of 19374:e655cb27d085.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
xen/include/asm-ia64/mm.h

index c4da3a18e5af052ca24ec55a1d776467b9fb87d7..b7b2d392174d24e59f5ea14ceb5656538b2e1ee3 100644 (file)
@@ -228,10 +228,18 @@ static inline struct domain *page_get_owner_and_reference(
 
     do {
         x = y;
-        if (unlikely((x & PGC_count_mask) == 0) ||  /* Not allocated? */
-            unlikely(((x + 1) & PGC_count_mask) == 0) ) {/* Count overflow? */
+        /*
+         * Count ==  0: Page is not allocated, so we cannot take a reference.
+         * Count == -1: Reference count would wrap, which is invalid.
+         * Count == -2: Remaining unused ref is reserved for get_page_light().
+         */
+        /*
+         * On ia64, get_page_light() isn't defined so that it doesn't
+         * make sense to take care of Count == -2.
+         * Just for consistency with x86.
+         */
+        if ( unlikely(((x + 2) & PGC_count_mask) <= 2) )
             return NULL;
-        }
         y = cmpxchg_acq(&page->count_info, x, x + 1);
     } while (unlikely(y != x));
 
@@ -247,7 +255,8 @@ static inline int get_page(struct page_info *page,
     if (likely(owner == domain))
         return 1;
 
-    put_page(page);
+    if (owner != NULL)
+        put_page(page);
 
     /* if (!domain->is_dying) */ /* XXX: header inclusion hell */
     gdprintk(XENLOG_INFO,